package com.m.imagelookview;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;


public class teActivity extends AppCompatActivity {

    private ImageView dsf;
    private Button dsfswb;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_te);

        initView();
    }

    private void initView() {
        final int[] i = {0};
        dsf = (ImageView) findViewById(R.id.dsf);
        Glide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg-article.pchome.net%2F00%2F43%2F75%2F06%2Fpic_lib%2Fwm%2Favatar_01.jpg&refer=http%3A%2F%2Fimg-article.pchome.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1611972179&t=37aa5664cbc75cd80ae7aed60559f7d7").into(dsf);
        dsfswb = (Button) findViewById(R.id.dsfswb);
        dsfswb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i[0]++;
                if (i[0] ==8){
                    i[0] =0;
                }
                switch (i[0]) {
                    case 0:
                        dsf.setScaleType(ImageView.ScaleType.CENTER);
                        break;
                    case 1:
                        dsf.setScaleType(ImageView.ScaleType.CENTER_CROP);
                        break;
                    case 2:
                        dsf.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                        break;
                    case 3:
                        dsf.setScaleType(ImageView.ScaleType.FIT_CENTER);
                        break;
                    case 4:
                        dsf.setScaleType(ImageView.ScaleType.FIT_END);
                        break;
                    case 5:
                        dsf.setScaleType(ImageView.ScaleType.FIT_START);
                        break;
                    case 6:
                        dsf.setScaleType(ImageView.ScaleType.FIT_XY);
                        break;
                    case 7:
                        dsf.setScaleType(ImageView.ScaleType.MATRIX);
                        break;
                }
                Log.e("测试", String.valueOf(i[0]));
            }
        });
    }
}
